﻿using System;
using System.Collections.Generic;
using System.Text;

public class RoomManager :Singleton<RoomManager>
{
    List<Room> rooms = new List<Room>();
    static int ROOM_ID_COUNT = 10000;//房间ID的序号

    public RoomManager()
    {

    }

    //获取一个有空位的房间
    public Room GetOneRoom()
    {
        for (int i = 0; i < rooms.Count; i++)
        {
            if(rooms[i].HasSeat())
            {
                return rooms[i];
            }
        }

        //没有空房间，新建一个
        Room newRoom = new Room(ROOM_ID_COUNT++);
        rooms.Add(newRoom);
        return newRoom;
    }

    public Room GetRoom(int roomId)
    {
        for (int i = 0; i < rooms.Count; i++)
        {
            if(rooms[i].id==roomId)
            {
                return rooms[i];
            }
        }
        return null;
    }
}
